<template>
	<view class="page">
		<view class="container">
		        <view class="imageRow" >
					<u-image :showLoading="true" style="margin-left:50rpx;" :src="imgBaseUrl3+detail.pic" width="700rpx" height="460rpx"></u-image>
		        </view>
		        <view class="rowTitle">{{detail.commodityName}}</view>
				<view class="row">
				    <view class="label">规格：</view>
				    <view  class="val">
									  {{detail.specificationItemNames}}
				    </view>
				 </view>
		        <view class="row">
		          <view class="label">{{'单价'}}：</view>
		          <text class="text money">￥{{detail.price}}</text>
		        </view>

				<view class="row">
					 <view class="label">数量：</view>
					{{detail.num}}
				</view>
				
				
				<view class="row">
					<view class="label">学生姓名：</view>{{detail.personName}}
				</view>
				<view class="row">
					<view class="label">学号：</view>{{detail.personCode}}
				</view>
				<view class="row">
					<view class="label">班级：</view>{{detail.departName}}
				</view>
				
				<view class="row">
				  <view class="label">{{'实付'}}：</view>
				  <text class="text money">￥{{detail.num*detail.price}}</text>
				</view>
				<view class="row">
				  <view class="label">{{'状态'}}：</view>
				  <text class="text">{{detail.status_dictText}}</text>
				</view>
		</view>

		<view class="footContent">
			<view class="handleBtn" style="width: 380rpx;" @click="goBack">
				返回
			</view>
			<view v-if="detail.status!=3" class="handleBtn cancelBtn" @click="handleCancel">
				取消订单
			</view>
		</view>
	</view>
</template>

<script>
	import {getCommodityDetailApi,cancelOrderApi} from '@/common/api/commonApi/uniformshop.js'
	export default {
		data() {
			return {
				detail:{},
				currentPrice: 0,
				id: '',
				size: '',

				specificatArr:[],

				buy:{id:"",price:null,commodityName:null,unitprice:null,num:1,specifications:[],specificationNames:""},
			}
		},
		components:{
		},
		methods: {

			handleCancel(){
				let data = {};
				data.id = this.detail.id;
				console.log(data)
				cancelOrderApi(data).then(res=>{
					console.log(res);
					if(res.success){
						this.setMessage("取消成功");
					}else{
						this.setMessage(res.message);
					}
				})
			},
			getDetail(){
				getCommodityDetailApi({
					commodityId: this.id
				}).then(res=>{
					this.detail = res.result
					this.buy.price = this.detail.price;
					this.buy.commodityName = this.detail.commodityName;
				})
			},
			setSpecificationNames(){
				this.buy.specificationNames = "";
				for(let i = 0;i<this.buy.specifications.length;i++){
					this.buy.specificationNames = this.buy.specificationNames+",";
					this.buy.specificationNames = this.buy.specificationNames + this.buy.specifications[i].name;
					this.buy.specificationNames = this.buy.specificationNames +":"+ this.buy.specifications[i].itemName;
				}
				this.buy.specificationNames = this.buy.specificationNames.substring(1,this.buy.specificationNames.length);
			},


		},
		onLoad() {
			this.detail = this.$Route.query.item;
			console.log(this.detail)

		},
		onShow() {
			
		},
	}
</script>

<style lang="scss" scoped>
.page{
	background-color: #f1f1f1;
	.container {
	    height: 100%;
	    background-color: #fff;
		padding-bottom: 50rpx;
	}
	.imageRow{
		display: flex;
		align-items: center;
		justify-content: center;
		padding: 20rpx 20rpx;
		
	}
	.row {
	    width: 100%;
	    padding: 20rpx 20rpx;
	    display: flex;
	    align-items: center;
	    /* border-top: 2rpx solid #e6e6e6; */
	}
	
	.text {
	    // width: 100%;
	    height: fit-content;
	    color: #333;
	}
	
	.label {
	    color: #9e9e9e;
	    width: 100rpx;
	    margin-left: 30rpx;
	}
	
	.rowTitle {
	    padding: 20rpx;
	    margin: 0 30rpx;
	    position: relative;
	    border-top: 2rpx solid #e6e6e6;
	}
	
	.rowTitle::after {
	    content: '';
	    position: absolute;
	    top: 50%;
	    left: 0rpx;
	    transform: translateY(-50%);
	    width: 7rpx;
	    height: 36rpx;
	    background: #4089f0;
	}
	
	.footContent{
		    width: 750rpx;
			height: 186rpx;
			background: #FFFFFF;
			box-shadow: 0px 0px 20rpx 0px rgba(102, 102, 102, 0.05);
			border-radius: 50rpx 50rpx 0px 0px;
			position: fixed;
			bottom: 0;
			display: flex;
			align-items: center;
			justify-content: space-around;
			font-size: 36rpx;
			padding: 0 20rpx;
			z-index: 10;
		.handleBtn{
			display: flex;
			align-items: center;
			justify-content: center;
			width: 260rpx;
			height: 100rpx;
			background: #4089f0;
			border-radius: 50rpx;
			color: #fff;
		}
		.cancelBtn{
			background-color: #f9ae3d !important;
		}
	}
	.money{
		color: #cc463d; 
		font-size: 38rpx;
	}
		
}
</style>
